<?php
$redis = new redis();
$redis->connect('127.0.0.1', 6379);
//$redis->auth('Np3jftX7808X')

//$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON);
//$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_MSGPACK);
$keys = ['string' => 'myset:string','int' => 'myset:int', 'bool'=>'myset:bool',
    'arr'=> 'myset:arr', 'incr' => 'myset:incr', 'incr1' => 'myset:incr1', 'incrStr' => 'myset:incrStr'];
//$redis->del($keys);exit;
$redis->set($keys['string'],"123");
$redis->set($keys['int'], 123);
$redis->set($keys['bool'], true);
$redis->set($keys['arr'],[1,2,3,4]); //保存数组，必须先设置序列化
$redis->incr($keys['incr']);
$redis->set($keys['incr1'], 60);  //保存整数可以实现自增
$redis->incr($keys['incr1']);
$redis->set($keys['incrStr'], '10');  //保存数字字符串,无法实现自增
$redis->incr($keys['incrStr']);
$result = $redis->mget($keys);
var_dump($result);
